#ifndef __TOYM__BASE__TIMESTAMP_H__
#define __TOYM__BASE__TIMESTAMP_H__

#include <cstdint>
#include <string>
#include <time.h>

namespace toym
{

class Timestamp {
public:
    Timestamp(std::int64_t ticks);
    
    // 默认拷贝构造函数是可用的
    // 默认拷贝赋值函数也是可用的
    
    std::int64_t getTick() const;
    bool isValid() const ;
    void toStructTm(struct tm*) const;
    std::string toString() const;
    std::string toFormatString() const;
    

    static
    Timestamp now();

    static
    Timestamp millionsecond(std::int64_t millionsecond);

    static
    Timestamp second(std::int64_t seconds);

    static
    Timestamp minute(std::int64_t minutes);

    static
    Timestamp hour(std::int64_t hours);

private:
    std::int64_t m_microseconds;
public:
    const static std::int64_t s_tickPerSecond = 1000000;
};

Timestamp operator+(Timestamp lhs, Timestamp rhs);
Timestamp operator-(Timestamp lhs, Timestamp rhs);
bool operator==(Timestamp lhs, Timestamp rhs);
bool operator<(Timestamp lhs, Timestamp rhs);
bool operator>(Timestamp lhs, Timestamp rhs);
bool operator<=(Timestamp lhs, Timestamp rhs);
bool operator>=(Timestamp lhs, Timestamp rhs);


} // namespace toym


#endif //__TOYM__BASE__TIMESTAMP_H__